<?php

/**
 * Smartform: server backend for http://plugins.jquery.com/project/smartform
 *
 * @author vbolshov
 */

namespace km\util;

class Smartform {
	static function success($data, $exit = true)
	{
		return self::respond(json_encode(array('data' => $data)), $exit);
	}
	static function failure($errors, $exit = true)
	{
		return self::respond(json_encode(
			array('errors' => (array) $errors)),
			$exit
		);
	}
	static private function respond($text, $exit)
	{
		if ($exit) {
			echo $text;
			exit;
		} else {
			return $text;
		}
	}
}
